//
//  BEAssignedTechsCell
//  BEGlobalOiler
//
//  Created by KKING on 16/9/9.
//  Copyright © 2016年 Bullseye Energy pte ltd. All rights reserved.
//

import UIKit

class BEAssignedTechsCell: UITableViewCell {

    var techModel: BEOrderTechModel = BEOrderTechModel(dict: ["":"" as AnyObject]){
        didSet{
            nameLabel.text = techModel.talentName
            statusLabel.text = techModel.statusName
            
            guard let urlString = techModel.photo else {
                return
            }
            let url = URL(string: urlString)
            iconImageView.kf.setImage(with: url, placeholder: #imageLiteral(resourceName: "avatar_default_big"), options: [], progressBlock: nil, completionHandler: nil)
        }
    }
            
    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var statusLabel: UILabel!
    
    
    @IBAction func callHimButtonDidClick(sender: UIButton) {
        
        let alertVC = UIAlertController(title: "CALL", message: "确定要呼叫"+"\(techModel.mobile ?? "")"+"吗?", preferredStyle: .alert)
        
        let cancleAction = UIAlertAction(title: "Cancle", style: .cancel, handler: nil)
        let doneAction = UIAlertAction(title: "OK", style: .default) { (_) in
            
            let url = NSURL(string: "tel://\(self.techModel.mobile)")
            UIApplication.shared.openURL(url! as URL)
        }
        
        alertVC.addAction(cancleAction)
        alertVC.addAction(doneAction)
        
        UIApplication.shared.keyWindow?.rootViewController!.present(alertVC, animated: true, completion: nil)

    }
    
    @IBAction func sendButtonDidClick(sender: UIButton) {
        let alertVC = UIAlertController(title: "IM尚未开放", message: nil, preferredStyle: .alert)
        let cancleAction = UIAlertAction(title: "Cancle", style: .cancel, handler: nil)
        let doneAction = UIAlertAction(title: "OK", style: .default, handler: nil)
        alertVC.addAction(cancleAction)
        alertVC.addAction(doneAction)
        
        UIApplication.shared.keyWindow?.rootViewController!.present(alertVC, animated: true, completion: nil)
    }


    
    
    
}
